#include "DocVector.h"

#include <math.h>
#include <iostream>

using namespace std;

DocVector::DocVector()
{
}

DocVector::~DocVector()
{
}

void DocVector::addWord(int pos, ResultMap *resultMap)
{
	double frequencia = resultMap->getAmountMatches(doc);
	//cout << "Freq: " << frequencia << endl;
	double n = resultMap->getAmountDocs();
	//cout << "numDocs: " << n << endl;
	double NDocs = 3000000;
	
	vetor[pos]=frequencia*log(NDocs/n);
	//cout << "Calculei um score de: " << frequencia*log(NDocs/n) << " para a palavra: " << resultMap->getWord() <<
	//" no Documento: " << doc << endl;
}

void DocVector::addNullUpTo(int pos)
{
	for(int i=0;i<pos;i++)
	{
		vetor.push_back(0);
	}
}

void DocVector::setDoc(string d)
{
	doc = d;
}

void DocVector::pushValue(double value)
{
	vetor.push_back(value);
}

uint DocVector::getDimensions()
{
	return vetor.size();
}

double DocVector::getCoef(int pos)
{
	return vetor[pos];
}

void DocVector::setPos(int pos, double value)
{
	vetor[pos]=value;
}